home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / ka9q / kit_src / mk_ftpu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  2.3 KB  |  74 lines

  1. /*    (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
  2.  * 
  3.  *    Redistribution and use in source and binary forms are permitted for
  4.  *    non-commercial use, provided that the above copyright notice and this
  5.  *    paragraph are duplicated in all such forms.  THIS SOFTWARE IS PROVIDED
  6.  *    ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  7.  *    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
  8.  *    FITNESS FOR A PARTICULAR PURPOSE.
  9.  */
  10. #include <stdio.h>
  11. #include <dir.h>
  12. #include "screen.h"
  13.  
  14. mk_ftpu(fnm)
  15. unsigned char fnm[];
  16. {
  17.     FILE *ftpu;
  18.     unsigned char buf[128], drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILE];
  19.     unsigned char ext[MAXEXT], tmp_path[128], tmp[10];
  20.     int n, m;
  21.  
  22.     strcpy(tmp_path, path);
  23.     m = strlen(tmp_path);
  24.     for (n = 0; n < m; n++)
  25.         if (tmp_path[n] == '\\')
  26.             tmp_path[n] = '/';
  27.     n = fnsplit(tmp_path, drive, dir, fname, ext);
  28.  
  29.     sprintf(buf, "%s\\%s", path, fnm);
  30.     if (debug)
  31.     {
  32.         printf("***> ftpusers file (%s):\n", buf);
  33.         ftpu = stdout;
  34.     }
  35.     else
  36.     {
  37.         if ( (ftpu = fopen(buf, "r")) != NULL )
  38.         {
  39.             printf("\n(%s) already exists, overwrite (y/n)?  ",buf);
  40.             scanf("%s", tmp);
  41.             if ( (tmp[0] != 'y') && (tmp[0] != 'Y') )
  42.             {
  43.                 fclose(ftpu);
  44.                 return 0;
  45.             }
  46.         }
  47.         fclose(ftpu);
  48.         if ( (ftpu = fopen(buf, "w")) == NULL )
  49.         {
  50.             printf("\nCan't open \"%s\" for write, aborting!\n\n", buf);
  51.             exit(-1);
  52.         }
  53.     }
  54.  
  55.     fprintf(ftpu, "# ============================================================\n");
  56.     fprintf(ftpu, "# PUBLIC/EXTERNAL ACCOUNTS\n");
  57.     fprintf(ftpu, "# ============================================================\n");
  58.     fprintf(ftpu, "#       1   = File read permission\n");
  59.     fprintf(ftpu, "#       2   = Non-destructive file write permission\n");
  60.     fprintf(ftpu, "#       4   = Delete and destructive file write permission\n");
  61.     fprintf(ftpu, "#       8   = Mbox AX.25 gateway permission\n");
  62.     fprintf(ftpu, "#       16  = Mbox telnet permission\n");
  63.     fprintf(ftpu, "#       32  = Mbox Netrom permission\n");
  64.     fprintf(ftpu, "#       64  = Mbox Remote control permission\n");
  65.     fprintf(ftpu, "#       128 = Disallow this user access\n");
  66.     fprintf(ftpu, "#\n");
  67.     fprintf(ftpu, "anonymous * %s%s/pub 59\n", dir, fname);
  68.     fprintf(ftpu, "bbs * %s%s/pub 59\n", dir, fname);
  69.     fprintf(ftpu, "%s * %s%s/pub 59\n", callsign, dir, fname);
  70.  
  71.     if (!debug)
  72.         fclose(ftpu);
  73. }
  74.